/*
Copyright 2014 Maciej SIDOR [maciejsidor@gmail.com]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.	
 */
package com.googlecode.msidor.maven.plugins.sybase.procedures;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.SQLWarning;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

/**
 * @author Maciej SIDOR
 * Mockup implementation of Statement for test purpose.
 * Only the methods that are used by Sybase MOJOs are implemented.
 */
public class StatementMockup implements Statement
{
	private List<ResultSet> results 			= new ArrayList<ResultSet>();
	private ResultSet 		currentResultSet 	= null;
	
	
	/*-------------------------Helpers-------------------------------------------------------*/
	
	public void addResultSet(ResultSet rs)
	{
		results.add(rs);		
	}	

	/*-------------------------Mocked interface implementations------------------------------*/
	
	@Override
	public boolean getMoreResults() throws SQLException
	{
		if(results.size()>0)
		{
			currentResultSet=results.remove(0);
			return true;
		}
		
		currentResultSet = null;
		return false;
	}	

	@Override
	public ResultSet getResultSet() throws SQLException
	{
		return currentResultSet;
	}	
	
	@Override
	public int getUpdateCount() throws SQLException
	{
		return results.size()>0?0:-1;
	}
	
	/*-------------------------Fake interface implementations--------------------------------*/
	/*Don't expect any comments here as bellow implementations do nothing*/
	
	@Override
	public boolean isWrapperFor(Class<?> arg0) throws SQLException
	{
		//nothing to do
		return false;
	}

	@Override
	public <T> T unwrap(Class<T> arg0) throws SQLException
	{
		//nothing to do
		return null;
	}

	@Override
	public void addBatch(String sql) throws SQLException
	{
		//nothing to do

	}

	@Override
	public void cancel() throws SQLException
	{
		//nothing to do

	}

	@Override
	public void clearBatch() throws SQLException
	{
		//nothing to do

	}

	@Override
	public void clearWarnings() throws SQLException
	{
		//nothing to do

	}

	@Override
	public void close() throws SQLException
	{
		//nothing to do

	}

	@Override
	public boolean execute(String sql) throws SQLException
	{
		//nothing to do
		return false;
	}

	@Override
	public boolean execute(String sql, int autoGeneratedKeys) throws SQLException
	{
		//nothing to do
		return false;
	}

	@Override
	public boolean execute(String sql, int[] columnIndexes) throws SQLException
	{
		//nothing to do
		return false;
	}

	@Override
	public boolean execute(String sql, String[] columnNames) throws SQLException
	{
		//nothing to do
		return false;
	}

	@Override
	public int[] executeBatch() throws SQLException
	{
		//nothing to do
		return null;
	}

	@Override
	public ResultSet executeQuery(String sql) throws SQLException
	{
		//nothing to do
		return null;
	}

	@Override
	public int executeUpdate(String sql) throws SQLException
	{
		//nothing to do
		return 0;
	}

	@Override
	public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException
	{
		//nothing to do
		return 0;
	}

	@Override
	public int executeUpdate(String sql, int[] columnIndexes) throws SQLException
	{
		//nothing to do
		return 0;
	}

	@Override
	public int executeUpdate(String sql, String[] columnNames) throws SQLException
	{
		//nothing to do
		return 0;
	}

	@Override
	public Connection getConnection() throws SQLException
	{
		//nothing to do
		return null;
	}

	@Override
	public int getFetchDirection() throws SQLException
	{
		//nothing to do
		return 0;
	}

	@Override
	public int getFetchSize() throws SQLException
	{
		//nothing to do
		return 0;
	}

	@Override
	public ResultSet getGeneratedKeys() throws SQLException
	{
		//nothing to do
		return null;
	}

	@Override
	public int getMaxFieldSize() throws SQLException
	{
		//nothing to do
		return 0;
	}

	@Override
	public int getMaxRows() throws SQLException
	{
		//nothing to do
		return 0;
	}

	@Override
	public boolean getMoreResults(int current) throws SQLException
	{
		//nothing to do
		return false;
	}	

	@Override
	public int getQueryTimeout() throws SQLException
	{
		//nothing to do
		return 0;
	}
	

	@Override
	public int getResultSetConcurrency() throws SQLException
	{
		//nothing to do
		return 0;
	}

	@Override
	public int getResultSetHoldability() throws SQLException
	{
		//nothing to do
		return 0;
	}

	@Override
	public int getResultSetType() throws SQLException
	{
		//nothing to do
		return 0;
	}


	@Override
	public SQLWarning getWarnings() throws SQLException
	{
		//nothing to do
		return null;
	}

	@Override
	public boolean isClosed() throws SQLException
	{
		//nothing to do
		return false;
	}

	@Override
	public boolean isPoolable() throws SQLException
	{
		//nothing to do
		return false;
	}

	@Override
	public void setCursorName(String name) throws SQLException
	{
		//nothing to do

	}

	@Override
	public void setEscapeProcessing(boolean enable) throws SQLException
	{
		//nothing to do

	}

	@Override
	public void setFetchDirection(int direction) throws SQLException
	{
		//nothing to do

	}

	@Override
	public void setFetchSize(int rows) throws SQLException
	{
		//nothing to do

	}

	@Override
	public void setMaxFieldSize(int max) throws SQLException
	{
		//nothing to do

	}

	@Override
	public void setMaxRows(int max) throws SQLException
	{
		//nothing to do

	}

	@Override
	public void setPoolable(boolean poolable) throws SQLException
	{
		//nothing to do

	}

	@Override
	public void setQueryTimeout(int seconds) throws SQLException
	{
		//nothing to do

	}



}
